home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / transfrm.rex < prev    next >
OS/2 REXX Batch file  |  1994-11-03  |  15KB  |  605 lines

  1. /********************************************************************/
  2. /*                                                                  */
  3. /* Transform Points  V1.3                                           */
  4. /*                                                                  */
  5. /* Converts (selected) Points to Spheres, Boxes, Discs or Cones     */
  6. /*                                                                  */
  7. /* ⌐ 1994  By  AndrΘ Hotz    -=< Imaginative Systems >=-            */
  8. /*                                                                  */
  9. /********************************************************************/
  10.  
  11.  
  12. call AddLib "LWModelerARexx.port", 0
  13.  
  14. ver = 'V1.3'
  15.  
  16. name = 'Transform Points '||ver
  17.  
  18. signal on error
  19. signal on syntax
  20.  
  21. surf  = CurSurface()
  22. layer = CurLayer()
  23.  
  24. call Req_Begin(name)
  25.  
  26. id1 = Req_AddControl('Transform Points to:','CH','Boxes' 'Spheres' 'Discs' 'Cones')
  27.  
  28. call Req_SetVal(id1,1)
  29.  
  30. if (~Req_Post()) then do
  31.         call Req_End()
  32.         exit
  33. end
  34.  
  35. typ = Req_GetVal(id1)
  36.  
  37. call Req_End()
  38.  
  39. /*************************   BOXES   ********************************/
  40.  
  41. if typ=1 then do
  42.  
  43. call Req_Begin(name||' - Transform to Boxes')
  44.  
  45. id1 = Req_AddControl('Size (XYZ)','V',1)
  46. id2 = Req_AddControl('Segments (XYZ)','V',1)
  47. id4 = Req_AddControl('Surface','R')
  48. id5 = Req_AddControl('Affected Points','CH','All' 'Selected')
  49. id6 = Req_AddControl('Remove existing Points','B')
  50. id9 = Req_AddControl('Put Objects into new Layer','B')
  51. id10= Req_AddControl('Save Options:','CH','None' 'Objects' 'Scene&Objects')
  52.  
  53. call Req_SetVal(id1,'1 1 1','1 1 1')
  54. call Req_SetVal(id2,'1 1 1','1 1 1')
  55. call Req_SetVal(id4,Surf)
  56. call Req_SetVal(id5,1)
  57. call Req_SetVal(id6,0)
  58. call Req_SetVal(id9,0)
  59. call Req_SetVal(id10,1)
  60.  
  61. if (~Req_Post()) then do
  62.     call Req_End()
  63.     exit
  64. end
  65.  
  66. size     = Req_GetVal(id1)
  67. segments = Req_GetVal(id2)
  68. surf     = Req_GetVal(id4)
  69. mode     = Req_GetVal(id5)
  70. cutoff   = Req_GetVal(id6)
  71. saveopt  = Req_GetVal(id10)
  72. copylay  = Req_GetVal(id9)
  73.  
  74. call Req_End()
  75.  
  76. if saveopt ~= 1  then filename  = GetFileName('Select Object Base Name')
  77. if saveopt  = 3  then scenename = GetFileName('Select Scene Name')
  78.  
  79. if mode=1 then call Sel_Mode(GLOBAL)
  80. if mode=2 then call Sel_Mode(USER)
  81.  
  82. call Surface(surf)
  83.  
  84. n = XFRM_Begin()
  85.  
  86. if n ~= 0 then do
  87.  
  88. do i = 1 to n
  89.   Point.i= XFRM_GetPos(i)
  90. end
  91.  
  92. call XFRM_End()
  93.  
  94. if cutoff ~= 0 then call Cut()
  95.  
  96. a = 2
  97.  
  98. if copylay ~= 0 then do
  99.   layer = layer+1
  100.   a = 1
  101.   call SetLayer(layer)
  102.   call Cut()
  103. end
  104.  
  105. call Notify(1,'!Now transforming 'n' Points to Boxes...')
  106.  
  107. x1=word(size,1)/2
  108. y1=word(size,2)/2
  109. z1=word(size,3)/2
  110.  
  111.  
  112. do i = 1 to n
  113.  
  114.    parse var Point.i x2 y2 z2
  115.  
  116.    low  = x2-x1||' '||y2-y1||' '||z2-z1
  117.    high = x2+x1||' '||y2+y1||' '||z2+z1
  118.  
  119.    call MakeBox(low,high,segments)
  120.    if ((saveopt ~= 1) & (filename ~= '(none)')) then do
  121.       call SetLayer(layer+a)
  122.       call Cut()
  123.       call MakeBox(low,high,segments)
  124.       call Save(filename||i)
  125.       call SetLayer(layer)
  126.    end
  127. end
  128. end
  129. if n=0 then call Notify(1,'!Error: No points to transform !')
  130.  
  131. end
  132.  
  133. /*************************  SPHERES  ********************************/
  134.  
  135. if typ=2 then do
  136.  
  137. call Req_Begin(name||' - Transform to Spheres')
  138.  
  139. id1 = Req_AddControl('Radius (XYZ)','V',1)
  140. id2 = Req_AddControl('Sides','N')
  141. id3 = Req_AddControl('Segments','N')
  142. id4 = Req_AddControl('Surface','R')
  143. id5 = Req_AddControl('Affected Points','CH','All' 'Selected')
  144. id6 = Req_AddControl('Remove existing Points','B')
  145. id9 = Req_AddControl('Put Objects into new Layer','B')
  146. id10= Req_AddControl('Save Options:','CH','None' 'Objects' 'Scene&Objects')
  147.  
  148. call Req_SetVal(id1,'1 1 1','1 1 1')
  149. call Req_SetVal(id2,16)
  150. call Req_SetVal(id3,8)
  151. call Req_SetVal(id4,Surf)
  152. call Req_SetVal(id5,1)
  153. call Req_SetVal(id6,0)
  154. call Req_SetVal(id9,0)
  155. call Req_SetVal(id10,1)
  156.  
  157. if (~Req_Post()) then do
  158.     call Req_End()
  159.     exit
  160. end
  161.  
  162. radius   = Req_GetVal(id1)
  163. sides    = Req_GetVal(id2)
  164. segments = Req_GetVal(id3)
  165. surf     = Req_GetVal(id4)
  166. mode     = Req_GetVal(id5)
  167. cutoff   = Req_GetVal(id6)
  168. saveopt  = Req_GetVal(id10)
  169. copylay  = Req_GetVal(id9)
  170.  
  171. call Req_End()
  172.  
  173. if saveopt ~= 1  then filename  = GetFileName('Select Object Base Name')
  174. if saveopt  = 3  then scenename = GetFileName('Select Scene Name')
  175.  
  176. if mode=1 then call Sel_Mode(GLOBAL)
  177. if mode=2 then call Sel_Mode(USER)
  178.  
  179. call Surface(surf)
  180.  
  181. n = XFRM_Begin()
  182.  
  183. if n ~= 0 then do
  184.  
  185. do i = 1 to n
  186.   Point.i= XFRM_GetPos(i)
  187. end
  188.  
  189. call XFRM_End()
  190.  
  191. if cutoff ~= 0 then call Cut()
  192.  
  193. a = 2
  194.  
  195. if copylay ~= 0 then do
  196.   layer = layer+1
  197.   a = 1
  198.   call SetLayer(layer)
  199.   call Cut()
  200. end
  201.  
  202. call Notify(1,'!Now transforming 'n' Points to Spheres...')
  203.  
  204. do i = 1 to n
  205.    call MakeBall(radius,sides,segments,Point.i)
  206.    if ((saveopt ~= 1) & (filename ~= '(none)')) then do
  207.       call SetLayer(layer+a)
  208.       call Cut()
  209.       call MakeBall(radius,sides,segments,Point.i)
  210.       call Save(filename||i)
  211.       call SetLayer(layer)
  212.    end
  213. end
  214.  
  215. end
  216. if n=0 then call Notify(1,'!Error: No points to transform !')
  217.  
  218. end
  219.  
  220. /*************************   DISCS   ********************************/
  221.  
  222. if typ=3 then do
  223.  
  224. call Req_Begin(name||' - Transform to Discs')
  225.  
  226. id1 = Req_AddControl('Radius (XYZ)','V',1)
  227. id11= Req_AddControl('Thickness','N',1)
  228. id2 = Req_AddControl('Sides','N')
  229. id3 = Req_AddControl('Segments','N')
  230. id13= Req_AddControl('Axis','CH','X' 'Y' 'Z')
  231. id4 = Req_AddControl('Surface','R')
  232. id14= Req_AddControl('Center Mode:','CH','DiscCenter' 'DiscTop' 'DiscBottom')
  233. id5 = Req_AddControl('Affected Points','CH','All' 'Selected')
  234. id6 = Req_AddControl('Remove existing Points','B')
  235. id9 = Req_AddControl('Put Objects into new Layer','B')
  236. id10= Req_AddControl('Save Options:','CH','None' 'Objects' 'Scene&Objects')
  237.  
  238. call Req_SetVal(id1,'1 1 1','1 1 1')
  239. call Req_SetVal(id2,16)
  240. call Req_SetVal(id3,8)
  241. call Req_SetVal(id4,Surf)
  242. call Req_SetVal(id5,1)
  243. call Req_SetVal(id6,0)
  244. call Req_SetVal(id11,1)
  245. call Req_SetVal(id13,1)
  246. call Req_SetVal(id9,0)
  247. call Req_SetVal(id10,1)
  248. call Req_SetVal(id14,1)
  249.  
  250. if (~Req_Post()) then do
  251.     call Req_End()
  252.     exit
  253. end
  254.  
  255. radius   = Req_GetVal(id1)
  256. sides    = Req_GetVal(id2)
  257. segments = Req_GetVal(id3)
  258. surf     = Req_GetVal(id4)
  259. mode     = Req_GetVal(id5)
  260. cutoff   = Req_GetVal(id6)
  261. saveopt  = Req_GetVal(id10)
  262. size     = Req_GetVal(id11)
  263. axisi    = Req_GetVal(id13)
  264. copylay  = Req_GetVal(id9)
  265. centerm  = Req_GetVal(id14)
  266.  
  267. call Req_End()
  268.  
  269. if axisi = 1 then axis='X'
  270. if axisi = 2 then axis='Y'
  271. if axisi = 3 then axis='Z'
  272.  
  273. if saveopt ~= 1  then filename  = GetFileName('Select Object Base Name')
  274. if saveopt  = 3  then scenename = GetFileName('Select Scene Name')
  275.  
  276. if mode=1 then call Sel_Mode(GLOBAL)
  277. if mode=2 then call Sel_Mode(USER)
  278.  
  279. call Surface(surf)
  280.  
  281. n = XFRM_Begin()
  282.  
  283. if n ~= 0 then do
  284.  
  285. do i = 1 to n
  286.   Point.i= XFRM_GetPos(i)
  287. end
  288.  
  289. call XFRM_End()
  290.  
  291. if cutoff ~= 0 then call Cut()
  292.  
  293. a = 2
  294.  
  295. if copylay ~= 0 then do
  296.   layer = layer+1
  297.   a = 1
  298.   call SetLayer(layer)
  299.   call Cut()
  300. end
  301.  
  302. call Notify(1,'!Now transforming 'n' Points to Discs...')
  303.  
  304. do i = 1 to n
  305.  
  306.    parse var Point.i x y z
  307.  
  308.    if axisi = 1 then do
  309.       if centerm = 1 then center=Point.i
  310.       if centerm = 2 then center=x+(size/2)||' '||y||' '||z
  311.       if centerm = 3 then center=x-(size/2)||' '||y||' '||z
  312.  
  313.       parse var center x y z
  314.  
  315.       top = x+(size/2)
  316.       bot = x-(size/2)
  317.  
  318.    end
  319.  
  320.    if axisi = 2 then do
  321.       if centerm = 1 then center=Point.i
  322.       if centerm = 2 then center=x||' '||y+(size/2)||' '||z
  323.       if centerm = 3 then center=x||' '||y-(size/2)||' '||z
  324.  
  325.       parse var center x y z
  326.  
  327.       top = y+(size/2)
  328.       bot = y-(size/2)
  329.    end
  330.  
  331.    if axisi = 3 then do
  332.       if centerm = 1 then center=Point.i
  333.       if centerm = 2 then center=x||' '||y||' '||z+(size/2)
  334.       if centerm = 3 then center=x||' '||y||' '||z-(size/2)
  335.  
  336.       parse var center x y z
  337.  
  338.       top = z+(size/2)
  339.       bot = z-(size/2)
  340.    end
  341.  
  342.    call MakeDisc(radius,top,bot,axis,sides,segments,center)
  343.  
  344.    if ((saveopt ~= 1) & (filename ~= '(none)')) then do
  345.       call SetLayer(layer+a)
  346.       call Cut()
  347.       call MakeDisc(radius,top,bot,axis,sides,segments,center)
  348.       call Save(filename||i)
  349.       call SetLayer(layer)
  350.    end
  351. end
  352. end
  353. if n=0 then call Notify(1,'!Error: No points to transform !')
  354. end
  355.  
  356. /*************************   CONES   ********************************/
  357.  
  358. if typ=4 then do
  359.  
  360. call Req_Begin(name||' - Transform to Cones')
  361.  
  362. id1 = Req_AddControl('Radius (XYZ)','V',1)
  363. id11= Req_AddControl('Thickness','N',1)
  364. id13= Req_AddControl('Axis','CH','X' 'Y' 'Z')
  365. id2 = Req_AddControl('Sides','N')
  366. id3 = Req_AddControl('Segments','N')
  367. id4 = Req_AddControl('Surface','R')
  368. id14= Req_AddControl('Center Mode:','CH','ConeCenter' 'ConeTop' 'ConeBottom')
  369. id5 = Req_AddControl('Affected Points','CH','All' 'Selected')
  370. id6 = Req_AddControl('Remove existing Points','B')
  371. id9 = Req_AddControl('Put Objects into new Layer','B')
  372. id10= Req_AddControl('Save Options:','CH','None' 'Objects' 'Scene&Objects')
  373.  
  374. call Req_SetVal(id1,'1 1 1','1 1 1')
  375. call Req_SetVal(id2,16)
  376. call Req_SetVal(id3,8)
  377. call Req_SetVal(id4,Surf)
  378. call Req_SetVal(id5,1)
  379. call Req_SetVal(id6,0)
  380. call Req_SetVal(id11,1)
  381. call Req_SetVal(id13,1)
  382. call Req_SetVal(id9,0)
  383. call Req_SetVal(id10,1)
  384. call Req_SetVal(id14,1)
  385.  
  386. if (~Req_Post()) then do
  387.     call Req_End()
  388.     exit
  389. end
  390.  
  391. radius   = Req_GetVal(id1)
  392. sides    = Req_GetVal(id2)
  393. segments = Req_GetVal(id3)
  394. surf     = Req_GetVal(id4)
  395. mode     = Req_GetVal(id5)
  396. cutoff   = Req_GetVal(id6)
  397. saveopt  = Req_GetVal(id10)
  398. size     = Req_GetVal(id11)
  399. axisi    = Req_GetVal(id13)
  400. copylay  = Req_GetVal(id9)
  401. centerm  = Req_GetVal(id14)
  402.  
  403. call Req_End()
  404.  
  405. if axisi = 1 then axis='X'
  406. if axisi = 2 then axis='Y'
  407. if axisi = 3 then axis='Z'
  408.  
  409. if saveopt ~= 1  then filename  = GetFileName('Select Object Base Name')
  410. if saveopt  = 3  then scenename = GetFileName('Select Scene Name')
  411.  
  412. if mode=1 then call Sel_Mode(GLOBAL)
  413. if mode=2 then call Sel_Mode(USER)
  414.  
  415. call Surface(surf)
  416.  
  417. n = XFRM_Begin()
  418.  
  419. if n ~= 0 then do
  420.  
  421. do i = 1 to n
  422.   Point.i= XFRM_GetPos(i)
  423. end
  424.  
  425. call XFRM_End()
  426.  
  427. if cutoff ~= 0 then call Cut()
  428.  
  429. a = 2
  430.  
  431. if copylay ~= 0 then do
  432.   layer = layer+1
  433.   a = 1
  434.   call SetLayer(layer)
  435.   call Cut()
  436. end
  437.  
  438. call Notify(1,'!Now transforming 'n' Points to Cones...')
  439.  
  440. do i = 1 to n
  441.  
  442.    parse var Point.i x y z
  443.  
  444.    if axisi = 1 then do
  445.       if centerm = 1 then center=Point.i
  446.       if centerm = 2 then center=x+(size/2)||' '||y||' '||z
  447.       if centerm = 3 then center=x-(size/2)||' '||y||' '||z
  448.       
  449.       parse var center x y z
  450.  
  451.       top = x+(size/2)
  452.       bot = x-(size/2)
  453.    end
  454.  
  455.    if axisi = 2 then do
  456.       if centerm = 1 then center=Point.i
  457.       if centerm = 2 then center=x||' '||y+(size/2)||' '||z
  458.       if centerm = 3 then center=x||' '||y-(size/2)||' '||z
  459.  
  460.       parse var center x y z
  461.  
  462.       top = y+(size/2)
  463.       bot = y-(size/2)
  464.    end
  465.  
  466.    if axisi = 3 then do
  467.       if centerm = 1 then center=Point.i
  468.       if centerm = 2 then center=x||' '||y||' '||z+(size/2)
  469.       if centerm = 3 then center=x||' '||y||' '||z-(size/2)
  470.  
  471.       parse var center x y z
  472.  
  473.       top = z+(size/2)
  474.       bot = z-(size/2)
  475.    end
  476.  
  477.    call MakeCone(radius,top,bot,axis,sides,segments,center)
  478.  
  479.    if ((saveopt ~= 1) & (filename ~= '(none)')) then do
  480.       call SetLayer(layer+a)
  481.       call Cut()
  482.       call MakeCone(radius,top,bot,axis,sides,segments,center)
  483.       call Save(filename||i)
  484.       call SetLayer(layer)
  485.    end
  486. end
  487. end
  488. if n=0 then call Notify(1,'!Error: No points to transform !')
  489. end
  490.  
  491.  
  492. if ((saveopt = 3) & (scenename ~= '(none)')) then call MakeScene()
  493.  
  494. if n ~= 0 then call Notify(1,'!Thanks for using Transform Points '||ver,'','@⌐ 1994 By AndrΘ Hotz','@of','-=> Imaginative Systems <=-','-=> Productions <=-','')
  495.  
  496.  
  497. call RemLib "LWModelerARexx.port"
  498. exit
  499.  
  500.  
  501. MakeScene:
  502.  
  503.    call METER_BEGIN(n+2,"Saving Scene...")
  504.  
  505.    If (~Open(Scene,scenename,'W')) then return
  506.  
  507.    call Writeln(Scene,"LWSC")
  508.    call Writeln(Scene,"1")
  509.    call Writeln(Scene," ")
  510.    call Writeln(Scene,"FirstFrame 1")
  511.    call Writeln(Scene,"LastFrame 1")
  512.    call Writeln(Scene,"FrameStep 1")
  513.    call Writeln(Scene," ")
  514.    call METER_STEP()
  515.    Do i=1 To n
  516.       call Writeln(Scene,"LoadObject "||filename||i)
  517.       call Writeln(Scene,"ObjectMotion (unnamed)")
  518.       call Writeln(Scene,"  9")
  519.       call Writeln(Scene,"  1")
  520.       call Writeln(Scene,"  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0")
  521.       call Writeln(Scene,"  0 0 0.0 0.0 0.0")
  522.       call Writeln(Scene,"  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0")
  523.       call Writeln(Scene,"  0 0 0.0 0.0 0.0")
  524.       call Writeln(Scene,"EndBehavior 1")
  525.       call Writeln(Scene,"ShadowOptions 7")
  526.       call Writeln(Scene,"")
  527.       call METER_STEP()
  528.    End
  529.    call Writeln(Scene,"AmbientColor 255 255 255")
  530.    call Writeln(Scene,"AmbIntensity 0.250000")
  531.    call Writeln(Scene,"")
  532.    call Writeln(Scene,"AddLight")
  533.    call Writeln(Scene,"LightName Light")
  534.    call Writeln(Scene,"LightMotion (unnamed)")
  535.    call Writeln(Scene,"  9")
  536.    call Writeln(Scene,"  1")
  537.    call Writeln(Scene,"  0.0 0.0 0.0 59.999996 29.999998 0.0 1.0 1.0 1.0")
  538.    call Writeln(Scene,"  0 0 0.0 0.0 0.0")
  539.    call Writeln(Scene,"EndBehavior 1")
  540.    call Writeln(Scene,"LightColor 255 255 255")
  541.    call Writeln(Scene,"LgtIntensity 1.000000")
  542.    call Writeln(Scene,"LightType 0")
  543.    call Writeln(Scene,"LensFlare 0")
  544.    call Writeln(Scene,"ShadowCasting 1")
  545.    call Writeln(Scene,"")
  546.    call Writeln(Scene,"CameraMotion (unnamed)")
  547.    call Writeln(Scene,"  9")
  548.    call Writeln(Scene,"  1")
  549.    call Writeln(Scene,"  0.0 0.0 -6.120000 0.0 0.0 0.0 1.0 1.0 1.0")
  550.    call Writeln(Scene,"  0 0 0.0 0.0 0.0")
  551.    call Writeln(Scene,"EndBehavior 1")
  552.    call Writeln(Scene,"ZoomFactor 3.200000")
  553.    call Writeln(Scene,"RenderMode 2")
  554.    call Writeln(Scene,"RayTraceEffects 0")
  555.    call Writeln(Scene,"Resolution 1")
  556.    call Writeln(Scene,"Overscan 1")
  557.    call Writeln(Scene,"Antialiasing 0")
  558.    call Writeln(Scene,"AdaptiveSampling 1")
  559.    call Writeln(Scene,"AdaptiveThreshold 8")
  560.    call Writeln(Scene,"FilmSize 2")
  561.    call Writeln(Scene,"FieldRendering 0")
  562.    call Writeln(Scene,"MotionBlur 0")
  563.    call Writeln(Scene,"DepthOfField 0")
  564.    call Writeln(Scene,"")
  565.    call Writeln(Scene,"SolidBackdrop 1")
  566.    call Writeln(Scene,"BackdropColor 0 0 0")
  567.    call Writeln(Scene,"ZenithColor 0 40 80")
  568.    call Writeln(Scene,"SkyColor 120 180 240")
  569.    call Writeln(Scene,"GroundColor 50 40 30")
  570.    call Writeln(Scene,"NadirColor 100 80 60")
  571.    call Writeln(Scene,"FogType 0")
  572.    call Writeln(Scene,"DitherIntensity 1")
  573.    call Writeln(Scene,"AnimatedDither 0")
  574.    call Writeln(Scene,"")
  575.    call Writeln(Scene,"ViewMode 3")
  576.    call Writeln(Scene,"ViewAimpoint 0.000000 0.000000 0.000000")
  577.    call Writeln(Scene,"ViewDirection 0.000000 -0.174533 0.000000")
  578.    call Writeln(Scene,"ViewZoomFactor 3.200000")
  579.    call Writeln(Scene,"LayoutGrid 3")
  580.    call Writeln(Scene,"GridSize 1.000000")
  581.    call Writeln(Scene,"ShowObjects 1")
  582.    call Writeln(Scene,"ShowBones 1")
  583.    call Writeln(Scene,"ShowLights 0")
  584.    call Writeln(Scene,"ShowCamera 1")
  585.    call Writeln(Scene,"ShowMotionPath 1")
  586.    call Writeln(Scene,"ShowSafeAreas 0")
  587.    call Writeln(Scene,"ShowBGImage 0")
  588.    call Writeln(Scene,"ShowFogRadius 0")
  589.    call Writeln(Scene,"ShowRedraw 0")
  590.  
  591.    call close(Scene)
  592.  
  593.    call METER_STEP()
  594.    call METER_END()
  595.  
  596. return
  597.  
  598.  
  599. syntax:
  600. error:
  601.   call end_all
  602.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  603.     exit
  604.  
  605.